function JSONP({ url, params, cbName }) {
  const generateUrl = () => {
    let src = "";
    for (let key of Object.keys(params)) {
      src += `${key}=${params[key]}&`;
    }

    return `${url}?${src}callback=${cbName}`;
  };

  return new Promise((resolve, reject) => {
    let scriptElm = document.createElement("script");
    scriptElm.src = generateUrl();
    document.body.appendChild(scriptElm);

    window[cbName] = (data) => {
      resolve(data);
      document.body.removeChild(scriptElm);
    };
  });
}
